// Jinx AJAX Framework
// Copyright (C) 2008 Blake Hegerle
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;
using Core;

namespace Formality.FormalSystem
{
    public class BinaryOperator : Tuple<Proposition>
    {
        public BinaryOperator(Proposition Prop, string Operator)
            : this(Prop)
        {
            if (this.Operator != Operator)
                throw new Exception(string.Format("Could not convert {0} to a binary operator of {1}",
                                                  Prop, Operator));
        }

        public BinaryOperator(Proposition Prop)
            : base(Prop)
        {
            if (Prop.Operands.Length != 2)
                throw new Exception(string.Format("{0} is not a binary operator", Prop));
        }

        public string Operator
        {
            get { return Item1.Operator; }
        }

        public Proposition Left
        {
            get { return Item1.Operands[0]; }
        }

        public Proposition Right
        {
            get { return Item1.Operands[1]; }
        }
    }
}